import Vue from 'vue'
import Router from 'vue-router'
import mysy from '../shangpin/mysy'
Vue.use(Router)
const router = new Router({
  routes: [
    {
      path: '/',
      name: 'mysy',
      component: mysy,
      meta: {
        tarber:true,
      }
    },
    // 商品详情
    {
      path: '/spxiangq',
      name: 'spxiangq',
      component: () => import('../shangpin/spxiangq.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
      }
    },
    // 订单详情
    {
      path: '/toddxq/:id',
      name: 'toddxq',
      props: true,
      component: () => import('../shangpin/dingdanxq.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
      }
    },
    // 本地生活
    {
      path: '/bendishuo',
      name: 'bendishuo',
      component: () => import('../shangpin/bendishuo.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
        tarber:true,
      }
    },
    // 我的
    {
      path: '/mymine',
      name: 'mymine',
      component: () => import('../wode/mymine.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
        tarber:true,
      }
    },
    // 热门拼团
    {
      path: '/remenpt',
      name: 'remenpt',
      component: () => import('../shangpin/remenpt.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
      }
    },
    // 快拼区
    {
      path: '/kuaipinqu',
      name: 'kuaipinqu',
      component: () => import('../shangpin/kuaipinqu.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
      }
    },
    // 拼客王
    {
      path: '/pinkewang',
      name: 'pinkewang',
      component: () => import('../shangpin/pinkewang.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
      }
    },
    // 新人区
    {
      path: '/myspelling',
      name: 'myspelling',
      component: () => import('../wode/myspelling.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
      }
    },
    // 拼团成功
    {
      path: '/pintuan',
      name: 'pintuan',
      component: () => import('../shangpin/pintuan.vue'),
      meta: {
        keepAlive: false, // 不需要缓存
      }
    },
    // 订单详情
    {
      path: '/successDetailspa',
      name: 'successDetailspa',
      component: () => import('../shangpin/successDetailspa.vue'),
      meta: {
        keepAlive: false, // 订单详情
      }
    },
    // 订单详情
    {
      path: '/remaining',
      name: 'remaining',
      component: () => import('../wode/remaining.vue'),
      meta: {
        keepAlive: false, // 订单详情
      }
    },
    // 钱包
    {
      path: '/walletdetail',
      name: 'walletdetail',
      component: () => import('../wode/walletdetail.vue'),
      meta: {
        keepAlive: false, // 订单详情
      }
    },
    // 登录
    {
      path: '/denglu',
      name: 'denglu',
      component: () => import('../wode/denglu.vue'),
      meta: {
        keepAlive: false, // 登录
      }
    },
  ]
})
router.beforeEach((to, from, next) => {
  
  next();
})
router.afterEach(route => {
  //loading加载完成
});
export default router;
/*
router.beforeEach((to, from, next) => {
  //可以做 loadong 开始加载 效果
  store.state.token = localStorage.getItem('userToken'); //获取本地存储的token
  if (to.meta.title) { //判断是否有标题  该操作可以再监听路由时候处理 watch:{'$route'(to,from){xxx操作}}
    document.title = to.meta.title
  }
  if (to.meta.requireAuth) { // 判断该路由是否需要登录权限
    if (store.state.token) { // 通过vuex state获取当前的token是否存
      console.log('有token时候', to, from, next)
      next();
    } else {
      console.log('没有token时候', to)
      next({
        path: '/login',
        query: { redirect: to.fullPath } // 将跳转的路由path作为参数，登录成功后跳转到该路由
      })
    }
  } else {
    next();
  }
})
*/
